#include <stdio.h>

int isLeapYear(int year)
{
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
    {
        return 1;
    }
    return 0;
}
int GetMonthDay(int year, int month)
{
    int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if (isLeapYear(year) && month == 2)
    {
        return 29;
    }
    return months[month];
}

int main()
{
    int y, m, d, n;

    n = 0;
    scanf("%4d%2d%2d", &y, &m, &d);
    for (int i = 1; i < m; ++i)

    {
        n += GetMonthDay(y, i);
    }
    n += d;
    printf("%d", n);
    return 0;
}